<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h3>JavaScript访问DOM数案例</h3>
		<h5>JavaScript使用api的4种方式：访问h3标签，a标签，获取它们内容。</h5>
		<h5>tagName、className、name、id</h5>
		
		<a href="http://www.taobao.com" target="_blank">淘宝</a>
		<a class="jd" href="http://www.jd.com" target="_blank">京东</a>
		<a name="pdd" href="http://www.pinduoduo.com" target="_blank">拼多多</a>
		<a id="cgb"  href="http://www.baidu.com" target="_blank">百度</a>
		<script>
			console.log( document.getElementsByTagName("a")[0].innerText ); //a标签内容
			console.log( document.getElementsByTagName("a")[0].href ); //a标签的href属性
			
			console.log(document.getElementsByClassName("jd")[0].innerText);
			console.log(document.getElementsByClassName("jd")[0].href);
			
			
			console.log( document.getElementsByName("pdd")[0].innerText );
			console.log( document.getElementsByName("pdd")[0].href );
			
			console.log( document.getElementById("cgb").innerText );
			console.log( document.getElementById("cgb").href );
			
			var a = document.getElementsByTagName("a")[0];
					a.innerText = "腾讯";
					a.href = "http://www.QQ.com";
		</script>
	</body>
</html>
